<?php

class Memmbers extends CI_Model {

    const Statustrue = True;
    const Statusflase = False;

    function __construct() {
        $this->load->helper('fuc');

        $this->load->library('topclass');
        parent::__construct();
    }

    function get_seller_info() {//来自api
        $res = $this->topclass->api_getUserGetRequest("UserSellerGetRequest", $_SESSION["usernick"], $_SESSION["sessionkey"]);
        objectToArray(&$res);
        return $res;
    }

    function get_user_level() {//来自api
        $sellerarray = $this->get_seller_info();
        return $sellerarray["user"]["seller_credit"]["level"];
    }

    function get_shop_info() {//来自api
        $res = $this->topclass->api_getShopGetRequest("ShopGetRequest", $_SESSION["usernick"]);
        objectToArray(&$res);
        return $res;
    }

    function handle_database_info() {//来自api
        $api_seller_array = $this->get_seller_info();
        $api_shop_array = $this->get_shop_info();
      

        $sql = "select * from join_memebers where  user_id={$api_seller_array["user"]["user_id"]} ";
        $query = $this->db->query($sql);
        $res = $query->result_array();
        // print_r($res);
        if (empty($res)) {
            $sql = "insert into join_memebers(shoplogourl,nickname,shopurl,level,user_id)values(
    \"{$api_shop_array["shop"]["pic_path"]}\",\"{$api_seller_array["user"]["nick"]}\", \"{$api_shop_array["shop"]["sid"]}\" ,\"{$api_seller_array["user"]["seller_credit"]["level"]}\"        
,\"{$api_seller_array["user"]["user_id"]}\"
)";
            $query = $this->db->query($sql);
            //   $res = $query->result_array();
        } else {
            
        }
    }

}

?>
